home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 59.8 KB | 2,255 lines | [TEXT/MPS ] |
- { stdtools.p © Copyright G. Sawitzki, StatLab Heidelberg 1988-1992}
-
- {To use StdTools, call gsInitToolbox once (only once!!!) at the very
- beginning of your program. StdTools will do all the necessary toolbox
- initialization for you. The following resources of StdTools.RSRC are
- vital for the operation of StdTools:
-
- Progress=129; Dialog for status report.
- The presence of this dialog is checked
- in SetResources, called by gsInitToolbox.
- StdDialog=128; Preloaded general purpose dialog -- for
- free use and modification.
-
- OkOrCancelAlert=131; Alert used for error handling
- AbortAlert=132; Alert used for error handling
-
- The following resources of StdTools.RSRC are vital for the operation of
- other parts of Template:
-
- MBarDisplayed=128; Menubar installed by SetUpTheMenus in unit
- Generic.
-
- The following resources are not vital
-
- Ferr=128; Stringlist with file error messages
- Merr=129; Stringlist with memory error messages
- Rerr=130; Stringlist with resource error messages
-
- **************************************************************************
- Resource ids from 1 to 256 are reserved for future extensions of StdTools.
- The following additional resources are used so far:
- OkOrCancelAlert=131; Alert resource id
- AbortAlert=132; Alert resource id
- BadConfiguration=133; Alert resource id
- LowConfiguration=134; Alert resource id
-
- **************************************************************************
-
- StdTools provides a simplified access to Macintosh toolbox routines.
- The naming conventions of MacApp have been adopted to faciliate an
- easy transition to MacApp.
-
-
- Areas covered/touched:
- error handling
- ••• to come •••
-
-
- updating history
- Things to do:
- support hierachical frames
- unify error handling
-
- Things done:
- 14 2.1992 gs added gWaitNextEventSleep
- 14.12.1991 gs added gEvent to hold current event
- 14.12.1991 gs added SetZoomOutSize
- 14.12.1991 gs added gCurApNamePtr
- 15. 8.1991 gs added gNextEventLoopTime
- 1. 8.1991 gs added gestaltVersionNr, SystemVersion in system
- 1. 8.1991 gs added hasAppleEvents in system
- 12. 5.1991 gs rename all 2d vars to 2dr to allow concurrent use of Graf3d
- 14. 2.1991 gs added delete of old file on close/rename
- 26.11.1990 gs checked for nil menuHandles
- 14. 2.1988 gs undo support added
- 6. 2.1988 gs file access unified, comments enhanced, queue management added
- 25.11.1987 gs multifinder support
- 12. 8.1987 gs dot simplified
- 30. 7.1987 gs packet initialization put first
- 29. 7.1987 gs alert package put at end.
- 28. 7.1987 gs alert handler concentrated.
- 28. 7.1987 gs main comment added
- 22. 7.1987 gs twindow/txframe added
- 12. 6.1987 gs old system structure recovered, adaptation to MPW/MacApp
- 15. 3.1987 gs dialogs/comments error handler added
- 3. 3.1987 ur comments cleaned up
- 25. 1.1987 gs lefttrim,righttrim,StrToSF, state cleaned up
- 19.10.1986 gs dialog & checkmark added
- 12. 9.1986 gs iocheck parameters changed. ioresult has to be supplied.
- 5. 9.1986 gs standard file routines
- 2. 7.1986 gs volume access via VRefNumber. input volume is set to default and
- kept fixed throughout process.
-
- ******************************************************************
- * Routines of most common interest / to start with:
- *
- * See
- * gsInitToolBox initializes toolbox. Has to be called
- * before using anything else in StdTools.
- * MakeAWindow makes a window
- *****************************************************************
-
-
- Special objects of StdTools:
-
-
- F R A M E S
-
- For scientific applications, we need windows with several "panes" and real
- world coordinates. These are implemented as "Frames". All frames belonging
- to one window share the grafport of this window. They can, however, have
- their own 2d coordinate systems. Setting to a frame will set to the port of
- the window, with the origin shifted to the topleft corner of the frame.
-
- MacApp Note: MacApp supports scrolling, but does not support 2d coordinates.
-
-
- C O M M A N D S-- Command numbers are used to communicate commands.
-
- The usual command handling is to translate any command - coming from menu
- selection, dialogs, application,... - to a menu number and then to pass
- this as a token. A proposed list of command codes is given at the end
- of the interface.
- For Edit-menu command numbers, we must guarantee that
- <command number> - cEditBase = <appropriate number to pass to SystemEdit>.
-
-
- T A S K C O N T R O L
-
- To allow some dynamic task control, the TaskStateType is used. Extend it,
- if you can stand it. Try to keep general status information within this
- structure
-
-
- E R R O R H A N D L I N G
-
- Standard error handling is done by the procedures ErrorReport and
- HandleFailure. Typical usage:
- I report an MyError. If the User askes for cancel, I handle the cancel
- request generically, or try to recover
-
- if ErrorReport(MyError,errRecovery+msgAlert)=cancel
- then
- HandleFailure(MyError,msgCancelled);
-
- wher MyError is on error code, typically of type OSErr.
-
- 4.1 note: message argument is not yet evaluated. Use for now:
- if ErrorReport(MyError,0)=cancel
- then
- HandleFailure(MyError,0);
-
- ErrorReport yields ok or cancel. It uses a standard string list.
- Format: <Token><Text>
- <Token>=A Abort only
- R Abort or retry
- A standard dialog is invoked if no error text is given. The TaskState
- is always set to TaskFatal.
-
- }
-
-
- UNIT StdTools;
- {© G. Sawitzki, 1986-1992}
- INTERFACE
-
- {$IFC undefined Think_Pascal}
- USES
- Types, Quickdraw, OSIntf, ToolIntf, PackIntf,SANE,GestaltEqu; { Standard Includes}
- {$ELSEC}
- USES
- SANE; { Standard Includes}
- {$ENDC}
-
-
- {avoid forcing units which are not really needed}
- {from traps:}
- const
- _InitGraf = $A86E;
- _Unimplemented = $A89F;
- _GestaltDispatch = $A0AD;
- {from syseq:}
- CurApName = $0910;
- Ticks = $16A;
- {[GLOBAL VAR] Current number of ticks since system startup (long)
- Tick count, time since boot [unsigned long]}
-
- {C O M M A N D S -- use these Command numbers to communicate commands.}
-
-
- {These command numbers are taken from MacApp.
- MacApp Note: In MacApp, not all of these are caught by MacApp. The list
- shows the following marks referring to MacApp:
- "<!>" means MacApp catches it.
- "<&>" means TEView catches it.
- "<->" means the application must catch it if it is used as a
- command number in any menu."}
-
-
- CONST
- cEventLoopDelay=3; {Macintosh heart beat rate: devault time interval
- to call WaitNextEvent}
-
- {Special command codes}
- cNoCommand = 0; {<!> Command number representing no command}
- cCantUndo = -1; {<!> Passed to indicate that the command
- cannot be undone.}
-
- {Apple-menu commands}
- cAboutApp = 1; {<!> "About <appname>…"}
-
- {File-menu filing commands}
- cNew = 10; {<!> "New" }
- cNewLast = 19; {(reserve a range of NEW commands)}
-
- cOpen = 20; {<!> "Open ..." (reserve a range of OPEN )}
- cOpenLast = 29;
-
- cSave = 30; {<!> "Save"}
- cClose = 31; {<!> "Close"}
- cSaveAs = 32; {<!> "Save as..."}
- cSaveCopy = 33; {<!> "Save a Copy in ..."}
- cRevert = 34; {<!> "Revert" (to previous version)}
- cShowClipboard = 35; {<!> "Show Clipboard"/"Hide Clipboard"}
- cQuit = 36; {<!> "Quit"}
-
- {Edit-menu commands}
- cEditBase = 101; {start of standard editing commands}
- cUndo = 101; {<!> "Undo <command>"/"Redo <command>"}
- cEditSep = 102; {line separating UNDO from CUT}
- cCut = 103; {<&> "Cut"}
- cCopy = 104; {<&> "Copy"}
- cPaste = 105; {<&> "Paste"}
- cClear = 106; {<-> "Clear"}
- cEditLast = cClear;
-
- cSelectAll = 110; {<&> "Select All"}
-
- cTyping = 120; {for use in a TTypingCommand}
- cMouseCommand = 121; {generic mouse command}
-
- {Finder pseudo-commands: what the user selected in the finder}
- cFinderNew = 40; {<!> selected the tool and chose "Open"}
- cFinderPrint = 41; {<!> selected document and chose "Print"}
- cFinderOpen = 42; {<!> selected document and chose "Open"}
-
- {File-menu printing commands }
- cPrFileBase = 176; {Command numbers between cPrFileBase}
- cPrFileMax = 195; {and cPrFileMax are to be handled by
- documents themselfes}
-
- cPageSetup = 176; {<!> "Page Setup..."}
- cPrintOne = 177; {<!> "Print One"}
- cPrint = 178; {<!> "Print..."}
- cPrintToFile = 179; {<!> "Print to file..."}
- cPrintSpoolFile = 190; {<-> "Print spooled file..."}
-
- cPrViewBase = 201; {Command numbers between cPrViewBase
- cPrViewMax = 250; {and cPrViewMax are to be handle by
- a view}
-
- cShowBorders = 199; {<!> Toggle. "Show view borders"}
-
- {Zooming commands} {Not being used at present}
- cReduce50 = 301; {<-> "Reduce 50%"}
- cReduceToFit = 302; {<-> "Reduce to Fit"}
- cShowFullSize = 303; {<-> "Show Full Size"}
-
-
-
- { T A S K C O N T R O L --- S t a t u s & E r r o r management }
-
-
- Type
-
- TaskStateType = (
- {Status Interpretation: Main Event Loop action:}
-
- TaskFatal, {a fatal error occured. call CleanUp and leave/bail out}
- TaskAbort, {user asked for abort. call CleanUp and leave/bail out}
- TaskExit, {all is done. call CleanUp and leave/bail out}
- TaskCancel, {user asked to cancel an action.step down a level}
- TaskFinished, {an action if finished. pass to task to step down a level}
- TaskOk, {an action is running. pass to task routine}
- TaskIdle, {no action is running.no task. wait for event}
- TaskNew {no action. no task. post menu new event}
- );
-
- BackPhase = (BackBegin, BackContinue, BackEnd); {if no event is pending}
- {BackBegin means: going to background; BackContinue: no change; BackEnd: to foreground}
-
- TrackPhase = (trackPress, trackMove, trackRelease); {not used now}
- CmdNumber=Integer; { type taken from MacApp }
-
-
- var
- {we n e v e r want to obstruct a user. So we keep one global variable telling
- when to return to the main event loop.}
-
- gNextEventLoopTime: longint; {time to call waitnextevent. Read-only. Set in
- main event loop }
- gWaitNextEventSleep: longint; {Sleep value to pass to next WaitNextEvent call.
- Should be set to the minimum of the sleep values for all handlers}
-
-
- {here are the methods to access this variable. These are one-liners. For speed,
- they can be expanded inline.}
-
- procedure SetEventLoopTime(maxdelay:longint);
- {sets the global variable gNextEventLoopTime. Recommended valus is 3,
- corresponding to 1/20 s}
-
- function IsEventLoopTime:boolean;
- {returns true if gNextEventLoopTime has expired}
-
-
- VAR {global variables. Do not use too many, or you are lost when you crash}
-
- {**************************************************
- Main information about current state of the program
- **************************************************}
- gCurApNamePtr: StringPtr;
- gTaskState : TaskStateType; {current task state}
- gErrorLatch:Integer; {last error id reported}
- gInBackground: boolean; {true if task is running in background}
-
- {**************************************************
- Information about the system environment
- **************************************************}
-
- System : RECORD {set by procedure setglobals}
- FileSystem : (MFS, HFS, UnixFS);
- OS : (Mac, MacPlus, Lisa, Unix);
- GraficModel:(QuickDrawModel,ColorQuickDrawModel,PostscriptModel);
- gestaltVersionNr:longint; {Gestalt manager version, or 0 if none}
- SystemVersion:longint; {lower word contains system version}
- hasAppleEvents: boolean;
- Rom:integer;
- Machine:integer;
- ScreenWidth, ScreenHeight : Integer;
- DragRect, GrowRect, ZoomRect : rect;
- WindowCount : integer; {memory for makeawindow}
- SFPutPoint, SFGetPoint : Point;
- WNEIsImplemented: boolean;
- MBarHeight: INTEGER; {Height of the menu bar in pixels}
- END;
-
- {**************
- Resource access
- ***************}
-
- watchHandle,crossHandle : CursHandle;
- gHomeResFile : integer; {the application resource file will be noted here}
- gStdDialog : DialogPtr; {set to point to dialog 128, if this is available}
-
- {***********************
- Undo Support
- ************************}
- gUndoHandle : Handle; {handle to recovery info. Must be disposable!}
- gUndoType : ResType; {PICT, TEXT…. Type of gUndoHandle info}
- gUndoOwner : Ptr; {windowptr, frameptr. Should identify document}
- gUndoAction : CmdNumber; {command to perform when undoing}
-
- {***********************
- Other global information
- ************************}
-
- {variables names adapted to UMacApp.p}
- gAppDone: BOOLEAN; {set this to TRUE when you want to terminate}
- gCouldPrint: BOOLEAN; {whether Printer code is accessible}
- gFinderPrinting:BOOLEAN; {TRUE iff the Finder started just for printing}
- gInitialized: BOOLEAN; {Set to TRUE at the end of IApplication}
- gMainEventMask: INTEGER; {Event mask used in main event loop.}
- gEvent: EventRecord;{Recent event -- maintained by main event loop}
- gMainFileType: OSType; {principal file type opened/printed;by default,
- TApplication.SFGetFilters returns a list of just this}
-
- gFileCount: INTEGER; {# files to open/print from finder; set in Init2}
-
- { additional state variables from MacApp. Not used in stdtools }
- gPrinting: BOOLEAN; {true iff currently Printing}
- gGotClipType: BOOLEAN;
- gPrefClipType: ResType;
- gClipClaimed: BOOLEAN; {Used by PerformCommand & ClaimClipboard to determine, if
- DoIt of a cut/copy cmd fails, whether the Clipboard had
- already been claimed by the new command or not}
-
- gOldScrapStuff: ScrapStuff;
- gNewScrapStuff: ScrapStuff;
- gSaveClip: RgnHandle;
- gSaveOrg: Point;
- gSavePort: WindowPtr;
-
- gNextSpaceMsg: LONGINT; {time when next low space message should
- be displayed}
-
-
- {
- ******************************************************************
- * general initialization routine
- ******************************************************************
- }
-
- PROCEDURE gsInitToolbox(callsToMoreMasters: INTEGER);
- {Call this the very first thing in your main program. Does the essential
- Toolbox initialization;In MacApp, if you also use the printing unit
- UPrinting, call InitPrinting just after you call InitToolbox}
-
-
-
- { a d j u s t f o r s c r e e n s i z e }
-
-
- PROCEDURE CenterRect (VAR GlobR : rect;vh:vhselect);
- PROCEDURE CenterWindow (wptr : WindowPtr;vh:vhselect);
- {Center...: Center a window/rectangle/alert/dialog to center of screen}
-
-
-
-
- { F I L E A C C E S S }
-
-
- {For more possibilities, see the file manager chapter of Inside Macintosh}
-
- { ••• things to do:open/close for non-Text files}
- Type
- TFilePtr = ^TFileInfo;
-
- {channel all file identification through this record.
-
- NOTE: fName and fRename may be nil, or may be a handle to a string
- trimmed to the actual length (less than 255 byte). In particular,
- NewFile and OldFile will trim the names, Rename has undefinded effects,
- and CloseFile will may it to NIL.
- If you are going to use functions which might change the length of the
- names, you may want to call SetHandleSize first to set it to maximum size.}
-
- TFileinfo = Record
- fValid : boolean; {true if the record contains valid info}
- fVolRefNum : integer; {the volume/working directory number}
- fFileType : OsType; {'TEXT' for text files, etc.}
- fName : StringHandle; {a handle to the actual name of the file.}
- fModDate : longint; {modification date}
- fRename : StringHandle; {nil,or handle to requested name}
- fActionToDo : integer; {use command constants}
- fDataRefNum : integer; {HFS reference number of data}
- fRsrcRefNum : integer; {HFS reference number of resources}
- fUserData : longint; {free for user}
- end;
-
- FUNCTION NameToInfo (namest : str255; var Fileinfo:TFileinfo):OsErr;
- {Translate Name or pathname to Fileinfo}
-
-
- FUNCTION OldFile (prompt : str255;FileType : OsType) :TFileInfo;
- {OldFile asks to select an existing file.FileType must be exactly four
- characters.If you do not want anything special ,call .. OldFile(´´,´´).}
-
- FUNCTION NewFile (prompt : str255;Proposal : str255) :TFileInfo;
- {NewFile asks to select an exitsting, or to define a new file.
- If you do not want anything special, call .. NewFile('',''); }
-
-
- PROCEDURE OpenRead (VAR Infile : text;var whichFile : TFileInfo);
- {keeps default volume intact.}
- PROCEDURE OpenWrite (VAR outfile : text;var whichFile : TFileInfo);
- {keeps default volume intact. Will create a temporary file if a file with
- the requested name already exists.}
- PROCEDURE CloseFile(VAR outfile : text;var whichFile : TFileInfo);
- {closes file, sets file type and calls rename if fRename is not NIL}
-
-
- FUNCTION FileExists (var whichFile : TFileInfo) : boolean;
- PROCEDURE FileCreate (var whichFile : TFileInfo);
- PROCEDURE FileDelete (var whichFile : TFileInfo);
- PROCEDURE FileRename (var whichFile : TFileInfo);
-
-
- FUNCTION FileErrorReport(whichErr:integer;
- message:Longint;var whichFile:TFileInfo):integer;
-
-
-
-
- { G R A F I C -- E x t e n s i o n s t o Q u i c k d r a w }
-
- PROCEDURE focus (r : rect);
- {focus drawing on r}
-
-
- PROCEDURE draw (fromx, fromy, tox, toy : integer);
- { draws a linie from (fromx,fromy) to (tox,toy) }
-
- PROCEDURE dot (h, v : integer);
- { draws a dot at (h,v) }
-
-
- { 2 d G r a p h i c s T y p e s a n d F u n c t i o n s}
-
-
- TYPE
- point2dR = RECORD
- x, y : real;
- END;
- port2dRptr = ^port2dR;
- port2dR = RECORD
- gport : grafptr;
- viewrect : rect;
- xleft, ytop, xright, ybottom : real; {real world coordinates}
- xfact, yfact : real; {factors for transformation}
- END;
-
- VAR
- theport2dR : port2dRptr; {current port will be noted here}
-
- PROCEDURE setport2dR (port : port2dRptr);
- {makes port the current 2dR-port and activates the corresponding Grafport}
- PROCEDURE viewp2dR (r : rect);
- {defines r to be the viewrect of the current 2dR-Port}
- PROCEDURE adaptcoord (port : port2dRptr);
- {sets scaling factors on the basis of the extreme values and
- of the viewrect of port.}
-
- {Typical use:
- openport2dR
- setcoord
- ....
- viewp2dR //viewport changed //
- adaptcoord(theport2dR) //adapt it//}
-
- PROCEDURE setcoord (left, top, right, bottom : real);
- {specifies real coordinates for viewRect}
-
- PROCEDURE open2dRport (port : port2dRptr);
- PROCEDURE moveto2dR (x, y : real);
- PROCEDURE lineto2dR (x, y : real);
- PROCEDURE drawl2dR (xfrom, yfrom, xto, yto : real);
- PROCEDURE mark2dR (x, y : real;ch : char);
- PROCEDURE dot2dR (x, y : real);
-
- PROCEDURE sel2dRwind (port : port2dRptr);
- {activates and shows the Window corresponding to port}
-
-
-
-
- { W i n d o w m a n a g e m e n t -- needs 2dR Graphics Types }
-
-
- { ••• forthcoming changes: channel all graphic access through Frames.
-
- main routines will be:
-
- FocusFrame(aFrame:FramePtr) :
- make the port/2dR-port belonging to aFrame the active port, and
- focus and clip on aFrame's rect.
-
- SelectFrame(aFrame:FramePtr) : make aFrames window the active, frontmost
- and visible window, and do FocusFrame
-
- SetFrame will be deleted.
- }
-
-
- {Linked lists used for subframes.}
- Type
- TxPtr = ^TxList;
- FramePtr = ^TxFrame;
-
- TxList = RECORD
- info : FramePtr;
- next : TxPtr
- END;
-
- {Attributes supported genrically for frames}
- TxFrameAttr = (
- G2dRFrame, {frame with 2dR coordinates - default}
- FrameWBorder {border drawn}
- );
-
- TxFrameType = SET OF TxFrameAttr;
-
- TxFrame = RECORD
- fWindow : WindowPtr; {to containing window}
- fId : Integer; {for consistency check only -- reserved}
- fContainer : FramePtr; {to direct container, if any}
- fContentRect : Rect; {boundary relative to fContainer or window}
- fFrameList : TxPtr; {List of contained frames}
- fPicture : PicHandle; {picture for update/recover if any}
- fFrameType : TxFrameType;
- CASE integer OF {additional information. subject to change.}
- 0 : (fCoordPointer : Ptr); {will point to real world port}
- 1 : (fPort : grafptr);
- 2 : (f2dRPort : port2dRPtr);
- END;
-
- VAR
- gTheFrame : FramePtr; {global. currently active frame}
-
- PROCEDURE setFrame (aFrame : FramePtr);
- {sets aFrame to be the current grafic output frame. The following will
- be set:
- The port and 2dR-port associated to aFrame will be made active.
- all coordinates will be set to the current frame, clipping will be
- constrained to aFrame. SetFrame does not bring the frame's window to
- the front, nor will it make the window visible if it is not already}
-
-
- FUNCTION newSubFrame (bigFrameP : FramePtr; FrameType : TxFrameType;
- FrameRect : Rect) : FramePtr;
- {creates a new subframe of bigFrame of type FrameType at FrameRect
- (rel. bigFrame). Makes the new frame the active one by calling setFrame}
-
- {PROCEDURE splitFrame (aFrame : FramePtr;
- count : integer;
- direction : vhselect;
- FrameType : TxFrameType);}
- {not yet implemented: split a frame to regular subframes.}
-
- {
- ******************************************************************
- * Routine of most common interest / to start with:
- ******************************************************************
- For more on window handling see the window manager chapter in
- inside Macintosh. For more on window usage, see the Frames… and
- Graf2dR… procedures in StdTools.}
-
- PROCEDURE makeawindow (title : str255;
- width, height : integer;
- windowDefid : integer);
- {makes a window of type windowDefid at default position.
- Use id=0 for standard. Use a negative number if you do not want
- a goAwayBox.
- Makeawindow also defines a default frame for this window.}
-
- procedure SetZoomOutSize (window:windowptr;h,v:integer);
- {set the stdstate for a window}
- {keepscreen not yet supported}
-
-
- { D i a l o g / M e n u - S u p p o r t }
-
-
- {For other possibilities, see the Dialog Manager and the Menu Manager
- Chapter of Inside Macintosh }
-
- {check mark support for menus}
-
- PROCEDURE ItemCheckMark (theDialog : DialogPtr;ItemNo, ChkMark : integer);
- {set check mark at ItemNo in theDialog. 0: off 1:on}
-
- PROCEDURE ChkOnOffMItem (MenuHdl : MenuHandle;item, first, last : Integer);
- {set ITEM in menu checked and all else in first..last as unchecked}
-
- FUNCTION GetOnOffMItem (MenuHdl : MenuHandle;first, last : Integer) : integer;
- {gets the first checked ITEM in menu. returns 0 if none is checked.}
-
-
- {radio button clusters}
-
- PROCEDURE PushRadioButton (theDlog : DialogPtr;item, first, last : integer);
- {set ITEM in menu checked and all else in first..last as unchecked}
-
- FUNCTION GetRadioButton (theDlog : DialogPtr;first, last : integer) : integer;
- {gets the first checked ITEM in dialog. returns 0 if none is checked.}
-
-
- {framing a default item}
-
- PROCEDURE FrameItem (theDialog : DialogPtr;ItemNo : integer);
- {draw a rounded corner frame around ItemNo in theDialog}
-
-
- {functions and procedures to read or write Items in a dialog}
-
- PROCEDURE ItemSetText (TheDialog : dialogptr;ItemNo : integer;itext : str255);
- {set itext to static/edit/ctl item ItemNo}
-
- PROCEDURE ItemGetText (TheDialog : dialogptr;ItemNo : integer;VAR itext : str255);
- {get itext from static/edit/ctl item ItemNo}
-
- FUNCTION ItemGetReal (theDialog : DialogPtr;ItemNo : integer) : extended;
- PROCEDURE ItemSetReal (theDialog : DialogPtr;ItemNo : integer;Value : extended;Form : DecForm);
- FUNCTION ItemGetNum (theDialog : DialogPtr;ItemNo : integer) : longint;
- PROCEDURE ItemSetNum (theDialog : DialogPtr;ItemNo : integer;Value : longint);
-
-
-
- { G e n e r a l Q u e u e M a n a g e m e n t }
-
-
- {This is a simple associative queue for general purpose. You would
- typically access a queue of this type by passing/requesting a pointer
- to the information of interest.
-
- Note: with MPW Pascal, the you must call PLHeapInit before using
- dynamic allocation. This is done in gsInitToolbox.
- With MPW, the UNIV attribute can be used to overwrite Pascals
- strong typing. With other compilers, you might need to delete
- the UNIV option, and to add your own type casting on calling these
- procedures, if you want to be able to pass typed pointers instead
- of the general PTR type.}
-
- TYPE
- tQueuePtr = ^tQueueElem;
- tQueueElem = record
- infoPtr : ptr;
- nextQElem : tQueuePtr;
- end;
-
- tQueueStatus = record
- first,last,current:tQueuePtr
- end;
-
- procedure QueueInit(var theStatus: univ tQueueStatus);
- {set all entries in theStatus to nil}
-
- function AddPtr(thePtr: univ Ptr;var theQueueStatus: univ tQueueStatus):osErr;
- {add the entry thePtr after Queue described by theQueueStatus}
-
- function nextinfoPtr(var theQueueStatus: univ tQueueStatus):Ptr;
- {Get an entry from current position of Queue described by theQueueStatus.
- Advances pointer: first ... last .. nil.. first..
- Does n o t delete queue entry}
-
- Procedure DiscardPtr(thePtr: univ Ptr;var theQueueStatus: univ tQueueStatus);
- {Discard an entry from the Queue. Does n o t dispose the info.
- Does nothing, if entry is not found. Advances Current, if necessary}
-
- Procedure DiscardFirst(var theQueueStatus: univ tQueueStatus);
- {Special case: discard first entry in queue}
-
-
-
- { M i s c a l l a n e o u s U t i l i t i e s}
-
-
- {string utilities}
- FUNCTION lefttrim (s : str255) : str255; {trim leading blanks off string s}
- FUNCTION righttrim (s : str255) : str255; {trim trailing blanks off string s}
-
-
- FUNCTION PAbortFlag : boolean; {true, if "apple dot" - abort is pending.}
-
- PROCEDURE ForgetUndo;
- {clear undo info. dispose memory, if possible}
- FUNCTION PutUndo(info:handle;infoType:ResType;owner:ptr;cmd:cmdNumber):OsErr;
- {note the info for undo. makes a copy of info}
- FUNCTION GetUndo(var info:handle;var infoType:ResType;
- var owner:ptr;var cmd:cmdNumber):OsErr;
- {returns a copy of the undo info, or NIL}
-
- PROCEDURE setwport (window : windowptr);
- { sets the grafport for window }
- PROCEDURE clearwindow (VAR window : windowptr);
- {clear the picture associated to a window}
-
- PROCEDURE idstamp (user : str255;VAR stampstring : str255);
- {gives a standard identification string in stampstring.
- stampstring is build from USER and the current time information.}
-
-
- {standard progress report.}
-
- PROCEDURE showprogress; {Brings a standard progress message to the screen}
- PROCEDURE progressreport (item : integer;what : str255);
- PROCEDURE hideprogress; {hides the standard progress message}
-
-
-
- { E R R O R H A N D L I N G }
-
-
- Const
- {Masks to identify special alert icons:}
- NoIcon=-1; {stopIcon,noteIcon,ctnIcon are define in dialog manager}
-
- OkOrCancelAlert=131; {Alert resource id}
- AbortAlert=132; {Alert resource id}
- BadConfiguration=133; {Alert resource id}
- LowConfiguration=134; {Alert resource id}
-
- var
- gErrorComment: Str255; {string passed as parameter ^3 by ErrrorReport}
-
-
- FUNCTION ErrorReport(which:integer;message:Longint):integer;
- {Performs alert defined by alertId, returns user message}
- PROCEDURE HandleFailure(err:OSErr;message:Longint); {•• not yet ready ••}
- {call ErrorAlert, and handle error condition appropriately}
- FUNCTION StdAlert(alertId:Integer;AlertIcon:Integer):integer;
- {display the alert in a standard way; no response}
-
- {for file error handling, see file access functions}
-
- {calls the low level debugger}
-
- procedure macsbug; inline $a9ff;
- procedure macsbugprint(s:str255);inline $abff;
-
-
-
-
- Implementation
-
- {© G. Sawitzki, StatLab Heidelberg 1986-1991}
-
- {SetEventLoopTime and IsEventLoopTime must be matched.
- The obvious implementation would be to use tickcounts.
- However IsEventLoop is prone to be called in the middle of
- user code. So we use low level Ticks for speed.}
-
- procedure SetEventLoopTime(maxdelay:longint);
- {sets the global variable gNextEventLoopTime. Recommended valus is 3,
- corresponding to 1/20 s}
- begin
- gNextEventLoopTime:=LongIntPtr(Ticks)^+maxdelay;
- end;
-
- function IsEventLoopTime:boolean;
- {returns true if gNextEventLoopTime has expired}
- begin
- IsEventLoopTime:=LongIntPtr(Ticks)^>=gNextEventLoopTime;
- end;
-
- { a d j u s t f o r s c r e e n s i z e }
-
-
- PROCEDURE CenterRect{(VAR GlobR : rect;vh:vhselect)};
- {Center a rectangle to center of screen}
- VAR xdel, ydel: integer;
- BEGIN
- xdel:=0;ydel:=0;
- WITH GlobR,system DO
- if vh=h then xdel := ((screenWidth - (right - left)) DIV 2) - left
- else ydel := ((screenHeight - (bottom - top)) DIV 2) - top;
- offsetRect(GlobR, xdel, ydel);
- END;
-
- PROCEDURE CenterWindow;
- {Center a window to center of screen}
- CONST
- MakeFront = False;
- VAR
- r, rbound : rect;
- BEGIN
- if Wptr<>nil then begin
- r := wptr^.portRect;
- rbound := wptr^.portbits.bounds;
- OffsetRect(r, -rbound.left, -rbound.top);
- CenterRect(R,vh);
- MoveWindow(wptr, r.left, r.top, MakeFront);
- end;
- END;
-
- { procedure CenterDialog (dptr : DialogPtr);}
- { needs no tricks, since DialogPtr=WindowPtr }
-
-
-
- {Error.ipl E R R O R H A N D L I N G }
-
-
- procedure freezeAlert(which:integer);
- {keep an alert in good position, and loaded. this should be done for all
- critical alerts before the time is high.}
- var tempalert:AlertTHndl;
- begin
- tempAlert:=AlertTHndl(Getresource('ALRT',which));
- if tempalert<>nil then begin
- hlock(Handle(tempalert));
- Centerrect(tempalert^^.boundsrect,h);
- couldalert(which);
- hunlock(Handle(tempalert));
- end;
- end;
-
- Procedure HandleFailure{(err:OSErr;message:Longint)};
- {call ErrorAlert, and handle error condition appropriately}
- begin {•• not yet ready. message is not yet evaluated ••}
- if errorReport(err,message)=ok then
- gTaskState:=TaskOk {recover}
- else {abort}
- begin gappdone:=true; gTaskState:=TaskAbort; end;
- gErrorLatch:=err;
- end;
-
- function StdAlert{(alertId:integer; alertIcon:integer)};
- {display the alert in a standard way}
-
- var tempAlert : AlertTHndl;
- i:integer;
- begin
- tempAlert := AlertTHndl(GetResource('ALRT', alertId));
- if tempalert=nil then
- begin {Fatal:could not process alert}
- sysbeep(2);gTaskState:=TaskFatal;
- stdalert:=cancel;sysbeep(2);
- end
- else begin
- Hlock(Handle(tempAlert));
- CenterRect(tempAlert^^.boundsRect,h);
- case AlertIcon of
-
- StopIcon: i := StopAlert(alertId, nil);
- NoteIcon: i := NoteAlert(alertId, nil);
- cautionIcon: i := CautionAlert(alertId, nil);
- otherwise i:=Alert(alertId, nil);
- end;
- HUnLock(Handle(tempAlert));
- StdAlert:=i;
- end;
- end;
-
- function ErrorReport;
- const {Resource ids for error message stringlists}
- Ferr=128;
- Merr=129;
- Rerr=130;
- var tempstr:str255;
- id,index,tempi:integer;
- class:char;
- begin
- id:=0;
- index:=abs(which);
- tempstr:='';
-
- {try to read the string}
- if (index>32) and (index<=61)
- then begin ID:=FErr; index:=index-32;end
- else if (index>107) and (index<=117) then
- begin ID:=MErr; index:=index-107;end
- else
- if (index>191) and (index<=196)
- then begin ID:=RErr; index:=index-191;end;
-
- if id<>0 then {try to read the string}
- GetIndString(tempstr,Id,index);
-
- if length(tempstr)=0 then begin {fake a string}
- numtostring(which,tempstr);
- tempstr:=concat('AOS-Error ',tempstr);
- end;
- class:=tempstr[1];
- delete (tempstr,1,1);
- paramtext(tempstr,'','',gErrorComment);
- if class='R' then tempi:=stdAlert(OkOrCancelAlert,StopIcon)
- else tempi:=StdAlert(AbortAlert,StopIcon);
-
- if tempi=ok then
- begin errorReport:=ok;gTaskState:=TaskFatal;
- end else
- begin errorReport:=cancel;gTaskState:=TaskFatal;end;
- end;
-
-
-
-
- { I n i t i a l i s a t i o n }
-
-
- var
- progressdrec : DialogRecord;
- StdDrec : DialogRecord; {StdDialogPtr is public}
-
- ProgressDialog : DialogPtr; {used to hold a standard progress message}
-
-
- PROCEDURE setglobals;
- CONST
- Rom85Loc = $28E;
- FSFCBLen = $3F6; {address of the low-memory File system global}
- getwidth = 348;{width sfgetfile-dialog}
- putwidth = 304;{sfpufile-Dialog}
- addrMBarHeight = $BAA;
- WNETrapNum=$60;
- UnImplTrapNum=$9F;
- VAR
- RomCheck : ^integer;
- HFSCheck : ^integer;
- MBarCheck: ^integer;
- Message:integer;
- gestaltavailable: boolean;
- l: longint;
-
- {Here again we do the work Apple could have done. See IM VI, Listing 3-1}
- function NumToolboxTraps: Integer;
- begin
- if NGetTrapAddress(_InitGraf,ToolTrap)=
- NGetTrapAddress($AA6E,ToolTrap) then
- NumToolBoxTraps:=$200
- else
- NumToolBoxTraps:=$400;
- end;
-
- function GetTrapType(theTrap:Integer): TrapType;
- const
- TrapMask=$0800;
- begin
- if BAnd(theTrap,TrapMask)>0 then
- GetTrapType:=ToolTrap
- else
- GetTrapType:=OsTrap;
- end;
-
- function TrapAvailable(theTrap:Integer): Boolean;
- var
- tType:TrapType;
- begin
- tType:=GetTrapType(theTrap);
- if tType=ToolTrap then
- begin
- theTrap:=band(theTrap,$07FF);
- if theTrap>=NumToolboxTraps then
- theTrap:=_UnImplemented;
- end;
- TrapAvailable:=
- NGetTrapAddress(theTrap,tType)<>NGetTrapAddress(_Unimplemented,ToolTrap);
- end;
-
- BEGIN
- gCurApNamePtr:=StringPtr(curapname);
-
- RomCheck := Pointer(Rom85Loc);
- HFSCheck := POINTER(FSFCBLen);
- gestaltavailable := TrapAvailable(_GestaltDispatch);
-
- {multiple screen support for drag and grow 26.11.1990 1:18:50 Uhr gs }
-
-
- WITH system, screenbits DO
- BEGIN
- if gestaltavailable then begin
- if Gestalt(gestaltVersion, gestaltVersionNr) <> noErr
- then gestaltVersionNr:=0;
- if Gestalt(gestaltSystemVersion, SystemVersion) <> noErr
- then gestaltVersionNr:=0;
- hasAppleEvents := (Gestalt(gestaltAppleEventsAttr, l) = noErr);
-
- end else begin
- gestaltVersionNr:=0;
- SystemVersion:=0;
- hasAppleEvents := false;
- end;
- dragrect:=GetGrayRgn^^.rgnBBox;
- InsetRect(dragrect, 4, 4); {avoid pushing windows off screen}
- dragrect.top := dragrect.top+MBarHeight; {save space for menu bar}
-
- growrect:=dragrect;
- IF HFSCheck^ > 0 THEN filesystem := HFS ELSE filesystem := MFS;
- {Unix etc not yet checked}
-
- environs(rom,machine);
-
- IF RomCheck^ = $7FFF THEN Os := MacPlus ELSE Os := Mac;
- {Lisa,Unix etc not yet checked}
-
- IF Bitand(RomCheck^,$C000)=0 then GraficModel:=ColorQuickDrawModel
- else GraficModel:=QuickDrawModel; {Postscript not yet implemented};
-
- {get the height of the menu bar (in pixel)}
- if OS=MacPlus then
- begin MBARcheck:=Pointer(addrMBarHeight); MBarHeight:=MBarCheck^;end
- else MBARHeight:=20;
-
-
- zoomrect := bounds; {get the full screen}
- InsetRect(zoomrect, 4, 4); {avoid pushing windows off screen}
- zoomrect.top := MBarHeight; {save space for menu bar}
-
-
- screenwidth := bounds.right - bounds.left;
- screenHeight := bounds.bottom - bounds.top;
-
- SFGetPoint.h := (screenwidth - getwidth) DIV 2; SFGetPoint.v := 50;
- SFPutPoint.h := (screenwidth - Putwidth) DIV 2; SFPutPoint.v := 50;
-
- windowcount := 0;
-
- {is wait next event implemented ?}
- WNEIsImplemented:=
- NGetTrapAddress(WNETrapNum,ToolTrap) <>
- NGetTrapAddress(UnimplTrapNum,ToolTrap);
- END;{system,screenbits}
-
- gTaskState:=TaskOk;
- gErrorLatch:=noErr;
- gAppDone:=false;
-
- gCouldPrint:=false;
- CountAppFiles(Message,gFileCount);
- gFinderPrinting:=(message=appPrint);
-
- gInitialized := FALSE; {will be set TRUE in IApplication}
- gMainEventMask:=everyEvent;
-
- gHomeResFile:=CurResFile;
-
- gInBackground:=FALSE;
- gPrinting:=false;
- gUndoHandle:=nil;
- ForgetUndo; {reset other entries of undo memory}
- END;
-
- procedure busyinstall; {install the busy cursor -- not yet}
- begin
- end;
-
- procedure setResources;
- {setup resources for Message/error handling. standalone only}
- label 999;
- const
- cProgressid = 129; { resource of progressdialog}
- cStdid =128; { resource of std dialog}
- var progressDLOG:DialogTHndl;
- tempstr:str255;
- temptype:ResType;
- TempId:integer;
- begin
- ProgressDialog := NIL; {fail-save. save way to read it here ?}
- progressDLOG:=DialogTHndl(GetResource('DLOG',cProgressid));
- if ResError<>noErr then goto 999;
-
- getResInfo(Handle(progressDLOG),tempid,temptype,tempstr);
- if (ResError<>NoErr) or (tempstr<>'Progress') then goto 999;
- {hope it is ok}
- progressdialog:=getnewdialog(cProgressid,@progressDREC,pointer(-1));
- Centerwindow(windowptr(progressdialog),h);
- coulddialog(cProgressid);
- releaseResource(Handle(progressDLOG));
-
- gStdDialog:=getnewdialog(cStdid,@StdDREC,pointer(-1));
- if resError<>NoErr then gStdDialog:=nil
- else begin
- Centerwindow(windowptr(gStdDialog),h);
- coulddialog(cStdid);
- end;
-
- freezeAlert(131);
- freezeAlert(132);
-
- 999:if progressDialog=NIL then {resource file missing}
- begin
- moveto(100,100);
- drawstring('•••• StdTools.RSRC Resources missing ••••');
- sysbeep(100);
- exittoshell;
- end;
-
- watchHandle:=getCursor(watchCursor);
- hNoPurge(Handle(watchHandle));
- crossHandle:=getCursor(crossCursor);
- hNoPurge(Handle(crossHandle));
- end;
-
- procedure gsInitToolbox;
- const {for dynamic heap management in MPW Pascal}
- cSizeHeap=$4000;
- cHeapDelta=$4000;
- cAllowNonCont=true;
- cForDispose=true;
- var
- applZone: THz;
- oldMoreMast: INTEGER;
-
- begin
-
- InitGraf(@thePort);
- InitFonts;
- InitWindows; {creates a non-relocatable for the WM port}
- FlushEvents(everyEvent - diskMask, 0);
- InitMenus;
- TEInit;
- InitDialogs(NIL);
- InitCursor;
- { SetStackSpace(stacksize);-- take from MacApp Uobj if necessary}
- MaxApplZone;
-
- {****this part should be in main segment****}
-
- { Here is a trick - Stolen from MacApp- sugested by Jerome C. }
- applZone := ApplicZone;
- oldMoreMast := applZone^.moreMast;
- applZone^.moreMast := oldMoreMast * callsToMoreMasters;
- MoreMasters;
- applZone^.moreMast := oldMoreMast;
-
- {for dynamic heap management in MPW Pascal}
- { PLHeapInit(cSizeHeap,cHeapDelta,NIL,cAllowNonCont,cForDispose);}
- {****this part could go to a temporary segment****}
- SetGlobals;
- SetResources;
- BusyInstall;
- end;
-
-
-
-
-
- {File.ipl: F I L E T O O L S P A C K A G E }
-
-
- { special file error handlers }
-
- function FileErrorReport;
- begin
- gErrorComment:=whichFile.fname^^;
- FileErrorReport:=ErrorReport(whichErr,message);
- end;
-
- procedure HandleFileError(whichErr:integer;whichfile:TFileInfo);
- var myerr:integer;
- begin
- if whicherr=noerr then myerr:=FlushVol(NIL,whichFile.fVolRefNum)
- else myerr:=whicherr;
- if myerr<>noerr then myerr:=fileErrorReport(myerr,0,whichfile);
- end;
-
-
- { conversion routines }
-
- Procedure ReplyToInfo (var Reply: SFReply;var Fileinfo:TFileinfo);
- begin
- with FileInfo do
- begin
- fValid:=Reply.good;
- fVolRefNum:=Reply.vRefNum;
- fFileType:=Reply.ftype;
- fName:=NewString(Reply.fName);
- fModDate:=0;
- fRename:=nil;
- end;
- end;
-
- Procedure InfoToReply (var Fileinfo:TFileinfo;var Reply: SFReply);
- begin
- with FileInfo do
- begin
- Reply.good:=fValid;
- Reply.copy:=(fRename<>nil);
- Reply.ftype:=fFileType;
- Reply.vRefNum:=fVolRefNum;
- Reply.version:=0;
- Reply.fName:=fName^^;
- end;
- end;
-
-
- FUNCTION NameToInfo {(namest : str255; var Fileinfo:TFileinfo):OsErr};
- VAR
- volname : str255;
- filename : str255;
- saveVol,VolRef, i : integer;
- myerr : oserr;
- BEGIN
- filename:=lefttrim(righttrim(namest)); {discard blank garbage}
- volname := '';
- NameToInfo:=NoErr; {default}
-
- i := pos(':', namest);
- if i>0 then {separate filename and volname}
- begin
- i:=length(filename);
- while filename[i]<>':' do i:=pred(i); {find last :}
- volname := copy(filename, 1, i);
- filename := copy(filename, i + 1, length(filename) - i);
- END;
-
- myErr := getVol(Nil, saveVol); VolRef:=saveVol;
-
- IF length(volname) <> 0 THEN
- BEGIN {translate volname to VRefNum}
- myErr := SetVol(@volname, 0); {add error check&HFS support!}
- if myerr=noErr then
- myErr := getVol(@volname, VolRef) else NameToInfo:=myErr;
- END;
-
- WITH Fileinfo DO
- BEGIN
- fValid := (myErr = noErr);
- fRename := Nil;
- fVolRefNum := VolRef;
- fName := NewString(filename);
- fModDate:=0;
- fFileType:='????';
- END;
- myErr := setVol(NIL, SaveVol);
- END;
-
-
- {OldFile asks to select an exitsting file. FileType must be exactly four}
- {characters. If you do not want anything special, call .. OldFile('',' '); }
-
- FUNCTION OldFile;
- CONST
- SFGetAll = -1;
- VAR
- typelist : sftypelist;
- NrTypes : integer;
- tempReply : SFReply;
- Helpfi:TFileinfo;
- BEGIN
- typelist[0] := FileType;
- IF FileType = ' ' THEN
- NrTypes := SFGetAll
- ELSE
- NrTypes := 1;
- sfgetfile(System.SFGetPoint, prompt, NIL, NrTypes, typelist, NIL, tempReply);
- ReplyToinfo(tempReply,Helpfi);
- oldFile:=Helpfi;
- END;{OldFile}
-
-
- {NewFile asks to select an exitsting, or to define a new file.}
- {If you do not want anything special, call .. NewFile('',''); }
-
- FUNCTION NewFile;
- VAR
- tempReply : SFReply;
- Helpfi:TFileinfo;
- BEGIN
- SFPutFile(System.SFPutPoint, prompt, Proposal, NIL, tempReply);
- ReplyToinfo(tempReply,Helpfi);
- newFile:=Helpfi;
- END;{NewFile}
-
-
- {FileExists }
- FUNCTION FileExists;
- VAR fndrinfo : Finfo;
- BEGIN
- WITH whichFile DO
- BEGIN
- IF NOT fValid THEN fileExists := false
- ELSE fileExists := (getFinfo(fname^^, fVolRefNum, fndrinfo) = NoErr);
- END;{with}
- END;
-
-
- PROCEDURE FileCreate;
- CONST NoCreator = ' ';
- BEGIN
- WITH whichFile DO
- HandleFileError(create(fname^^, fVolRefNum, NoCreator, fFiletype),whichFile);
- END;
-
-
- PROCEDURE FileDelete;
- BEGIN
- WITH whichFile DO
- HandleFileError(FSDelete(fname^^, fVolRefNum),whichfile);
- END;
-
-
- PROCEDURE FileRename;
- BEGIN
- WITH whichFile DO begin
- if (fname<>nil) and (fRename<>nil) then
- HandleFileError(Rename(fname^^, fVolRefNum, fRename^^),whichfile);
- end; {with}
- END;
-
- { To do: is there a unified way to open Text- or other files, which works
- for all compilers ?}
-
- PROCEDURE OpenWrite;
- {keeps default volume intact}
- VAR tempname:str255;
- tempPtr:stringPtr;
- oldvolref : integer;
- fndrInfo : Finfo;
- myerr:integer;
- BEGIN
- WITH whichfile DO
- BEGIN
- IF FileExists(whichFile) THEN
- begin {needs rename}
- fRename:=fName;
- tempPtr:=@tempname;
- fname:=@tempPtr;
- hlock(Handle(fRename));
- repeat {try to find an unused temporary file name}
- idStamp(fRename^^,tempname);
- if length(tempName)>31 then
- tempname:=copy(tempname,length(tempName)-31,31);
- until (not fileExists(whichFile)) or PAbortFlag;
- hunlock(Handle(fRename));
- fName:=NewString(tempName);
- end;
-
- if gTaskState<>TaskFatal then FileCreate(whichFile);
- if gTaskState<>TaskFatal then begin
- WITH whichfile DO
- BEGIN
- myerr:= getfinfo(fname^^, fVolRefNum, fndrinfo);
- fndrinfo.fdtype := fFileType;
- if myerr=noerr then myerr:= Setfinfo(fname^^, fVolRefNum, fndrinfo);
- END;
-
- if myerr=noerr then myerr:= getvol(NIL, oldvolref); {not old}
- IF gTaskState = TaskOk THEN
- if myerr=noerr then myerr:= setvol(NIL, whichfile.fVolRefNum); {just for crazy TML file handling}
- IF gTaskState = TaskOk THEN
- BEGIN
- rewrite(OutFile, fname^^);
- if myerr=noerr then myerr:= setvol(NIL, oldvolref); {reset it}
- END;
- END;{with}
- HandleFileError(myerr,whichfile);
- end;{if gTaskState<>TaskFatal then }
- END;
-
-
- PROCEDURE OpenRead;
- {keeps default volume intact}
- VAR
- oldvolref : integer;
- myerr:integer;
- BEGIN
- WITH whichfile DO
- BEGIN
- myerr:= getvol(NIL, oldvolref); {not old}
- if myerr=noerr then myerr:= setvol(NIL, whichfile.fVolRefNum);
- {just for crazy TML file handling}
- IF myerr=noerr THEN
- BEGIN
- reset(Infile, fname^^);
- if myerr=noerr then myerr:= setvol(NIL, oldvolref); {reset it}
- END;
- END;{with}
- HandleFileError(myerr,whichfile);
- END;
-
- PROCEDURE CloseFile(VAR outfile : text;var whichFile : TFileInfo);
- var fndrinfo:Finfo;
- myErr:integer;
- begin
- close(outfile);
-
- {adjust type and creator}
- WITH whichfile DO
- BEGIN
- myerr:= getfinfo(fname^^, fVolRefNum, fndrinfo);
- fndrinfo.fdtype := fFileType;
- if myerr=noerr then myerr:= Setfinfo(fname^^, fVolRefNum, fndrinfo);
- END;
-
- HandleFileError(myerr,whichfile); {14.2.1991 10:04:46 Uhr gs }
- if whichfile.fRename<>Nil then
- BEGIN
- WITH whichfile DO
- if getFinfo(fRename^^,fVolRefNum,fndrinfo)=noErr then {old file exists}
- HandleFileError(FSDelete(fRename^^,fVolRefNum),whichfile); {delete old file}
- FileRename(whichFile);
- END;
-
- end;
-
-
- { G R A F I C S }
-
-
- PROCEDURE focus {(r : rect)};
- {focus drawing on r}
- VAR
- dh, dv : integer;
- BEGIN
- dh := thePort^.portrect.left - r.left;
- dv := thePort^.portrect.top - r.top;
- setorigin(dh, dv);
- offsetrect(r, -r.left, -r.top);
- cliprect(r);
- END;
-
-
-
-
- PROCEDURE draw;
- BEGIN
- moveto(fromx, fromy);
- lineto(tox, toy);
- END;
-
- PROCEDURE setport2dR; {(port:port2dRptr)}
- BEGIN
- theport2dR := port;
- setport(theport2dR^.gport);
- END;
-
- PROCEDURE viewp2dR; {(r:rect)}
- BEGIN
- theport2dR^.viewrect := r;
- END;
-
- PROCEDURE adaptcoord; {(port:port2dRptr)}
- BEGIN
- WITH port^ DO
- BEGIN
- xfact := (viewrect.right - viewrect.left) / (xright - xleft);
- yfact := (viewrect.bottom - viewrect.top) / (ybottom - ytop);
- END;
- END;
-
- PROCEDURE setcoord; {left, top, right, bottom : real}
- BEGIN
- WITH theport2dR^ DO
- BEGIN
- xleft := left;
- ytop := top;
- xright := right;
- ybottom := bottom;
- adaptcoord(theport2dR);
- END;
- END;
-
- PROCEDURE open2dRport; {port : port2dRptr}
- BEGIN
- theport2dR := port;
- port^.gport := theport;
- port^.viewrect := theport^.portrect;
- WITH theport^.portrect DO
- setcoord(left, top, right, bottom);
- END;
-
- PROCEDURE moveto2dR; {x, y : real}
- BEGIN
- WITH theport2dR^ DO
- moveto(round((x - xleft) * xfact + viewrect.left), round((y - ytop) * yfact + viewrect.top));
- END;
-
- PROCEDURE lineto2dR; {x, y : real}
- BEGIN
- WITH theport2dR^ DO
- lineto(round((x - xleft) * xfact + viewrect.left), round((y - ytop) * yfact + viewrect.top));
- END;
-
- PROCEDURE drawl2dR; {xfrom, yfrom, xto, yto : real}
- BEGIN
- moveto2dR(xfrom, yfrom);
- lineto2dR(xto, yto);
- END;
-
- PROCEDURE mark2dR; {x, y : real; ch : char}
- BEGIN
- moveto2dR(x, y);
- drawchar(ch);
- END;
-
-
- { dot-proceduren für scatterplots }
-
- {support procedures}
-
- PROCEDURE dotHere;
- VAR
- r : rect;
- p1, p2 : point;
- oldpenstate: penstate;
- begin
- getpenstate(oldpenstate);
- move(-1,-1);
- pensize(2,2);
- line(0,0);
- setPenstate(oldpenstate);
- drawchar(' ');
- end;
-
- PROCEDURE dot;
- BEGIN
- moveto(h, v);
- dothere;
- END;
-
-
- PROCEDURE dot2dR;
- BEGIN
- moveto2dR(x, y);
- dothere;
- END;
-
-
- PROCEDURE sel2dRwind;
- BEGIN
- setport2dR(port);
- selectwindow(windowptr(port^.gport));
- showwindow(windowptr(port^.gport));
- END;
-
- { W i n d o w --
- for other possibilities, see the Window Manager chapter in Inside Macintosh}
-
- CONST
- {version codes -- for internal use}
- cVsTxFrame = 1;
-
- FUNCTION newSubFrame;
- VAR
- bounds : rect;
- mypeek : windowpeek;
- mywindow : windowptr;
- myG2dRPtr : port2dRptr;
- testpt : point;
- scr, pos : integer;
- xList : TxList;
- xListP : TxPtr;
- xFrame : FramePtr;
- bigFrame : txFrame;
- BEGIN
- setFrame(bigFrameP); {create a default Graf2dR port}
- new(myG2dRPtr);
- open2dRPort(myG2dRPtr);
- bigFrame := bigFrameP^;
- {we are the only frame}
- new(xFrame);
- WITH xFrame^ DO
- BEGIN
- fWindow := bigFrame.fWindow;
- fID := cVsTxFrame;
- fContainer := BigFrameP;
- fContentRect := FrameRect;
-
- fFrameList := NIL;
- fFrameType := FrameType;
- f2dRPort := MyG2dRPtr;
- fPicture := NIL;
- END;
- {insert to list in bigframe}
- new(xlistP);
-
- WITH xlistP^ DO
- BEGIN
- info := xframe;
- next := bigframe.fFrameList;
- END;
- bigframeP^.fFrameList := xlistP;
-
- newSubFrame := xFrame;
- END;
-
-
- PROCEDURE setframe;
- VAR
- r : rect;
- BEGIN
- gTheFrame := aFrame;
- WITH aFrame^ DO
- BEGIN
- IF g2dRFrame IN fFrameType THEN
- setPort2dR(f2dRPort)
- ELSE
- setPort(fPort);
- {we are in the container's port now. clip to 2dR port}
- setorigin(-fContentRect.left, -fContentRect.top);
- r := fContentRect;
- OffsetRect(r, -fContentRect.left, -fContentRect.top);
- cliprect(r);
- END;
- END;
-
- PROCEDURE makeawindow;
- {Generate a new window at default position}
-
- CONST
- xmaxpos = 16;
- ymaxpos = 11;
- offset = 20;
- delx = 5;
- dely = 45;
-
- VAR
- bounds : rect;
- mywindow : windowptr;
- myG2dRPtr : port2dRptr;
- testpt : point;
- scr, pos : integer;
- xList : TxList;
- xFrame : FramePtr;
-
- FUNCTION NewCWindow(wStorage: Ptr; boundsRect: Rect; title: Str255;
- visible: BOOLEAN; procID: INTEGER; behind: WindowPtr;
- goAwayFlag: BOOLEAN; refCon: LONGINT): WindowPtr;
- INLINE $AA45;
-
- BEGIN
- testpt.h := offset + delx; {topleft windowposition free ?}
- testpt.v := offset + dely;
- scr := findWindow(testpt, mywindow);
- WITH system DO
- BEGIN
- IF (myWindow = NIL) OR (WindowCount < 0) THEN
- WindowCount := 0; {If no window in home position:take it}
- WindowCount := succ(WindowCount);
- pos := WindowCount;
- END;
- WITH bounds DO
- BEGIN
- left := pos MOD xmaxpos * offset + delx;
- top := pos MOD ymaxpos * offset + dely;
- IF NOT PtInRect(topleft, System.DragRect) THEN
- topleft := System.DragRect.topleft;
- right := left + width;
- bottom := top + height;
- END;
- if system.graficmodel=ColorQuickDrawModel then
- mywindow :=
- newCwindow(NIL, bounds, title, true,
- abs(windowDefId), pointer(-1),
- (windowDefId>=0), 0)
- else mywindow :=
- newwindow(NIL, bounds, title, true,
- abs(windowDefId), pointer(-1),
- (windowDefId>=0), 0);
-
- setport(mywindow);
- clipRect(thePort^.Portrect); {avoid dissipating pictures. see technote #59}
-
- {create a default Graf2dR port}
- new(myG2dRPtr);
- open2dRPort(myG2dRPtr);
-
- {we are the only frame}
- new(xFrame);
- WITH xFrame^ DO
- BEGIN
- fWindow := MyWindow;
- fID := cVsTxFrame;
- fContainer := NIL;
- fContentRect := theport^.portrect;
- fFrameList := NIL;
- fFrameType := [G2dRFrame];
- f2dRPort := MyG2dRPtr;
- fPicture := NIL;
- END;
-
- setwrefcon(mywindow, longint(xFrame));
-
- setFrame(xFrame);
-
- END;
-
- procedure SetZoomOutSize (window:windowptr;h,v:integer);
- {set the stdstate for a window}
- type
- wpp = ^wstatedata;
- var
- p: wpp;
- begin
- p := wpp(windowpeek(window)^.datahandle^);
- with p^.stdState do begin
- {if larger than requested: trim}
- right:=left+h;
- if right>system.screenwidth then right:=system.screenwidth;
-
- bottom:=top+v;
- if bottom>system.screenheight then bottom:=system.screenheight
- end;
- end;
-
-
- {userifc.ipl implementations of usual features of the human interface}
-
- {dialog & ctl tools }
- PROCEDURE ItemCheckMark;
- VAR ItemType : Integer;
- ItemBox : Rect;
- ItemHdl : Handle;
- BEGIN
- GetDItem(theDialog, ItemNo, ItemType, ItemHdl, ItemBox);
- if ItemHdl<> nil then SetCtlValue(ControlHandle(ItemHdl), ChkMark);
- END;
-
-
- PROCEDURE ChkOnOffMItem(MenuHdl : MenuHandle;item, first, last : Integer);
- {set ITEM in menu checked and all else in first..last as unchecked}
- VAR i : integer;
- BEGIN
- if MenuHdl<> nil then begin
- if first<1 then first:=1;
- i:=countMitems(MenuHdl); if last>i then last:=i;
- FOR i := first TO last DO
- CheckItem(MenuHdl, i, (item=i)); {check it i on, others off in menu}
- end;
- END;
-
-
- FUNCTION GetOnOffMItem;
- {gets the first checked ITEM in menu. returns 0 if none is checked.}
- VAR index, loopindex : integer;
- markChar : char;
- BEGIN
- if MenuHdl=nil then GetOnOffMItem:=0 else begin
- if first<1 then first:=1;
- index:=countMitems(MenuHdl); if last>index then last:=index;
- index := 0; loopindex := first;
- WHILE (loopindex <= last) AND (index = 0) DO
- BEGIN
- GetItemMark(MenuHdl, loopindex, markChar); {check it in menu}
- IF markChar <> chr(0) THEN index := loopindex;
- loopindex := loopindex + 1;
- END;{while}
- GetOnOffMitem:=index;
- end;
- END;
-
-
- PROCEDURE PushRadioButton (theDlog : DialogPtr;item, first, last : integer);
- {set ITEM in menu checked and all else in first..last as unchecked}
-
- VAR
- index : integer; {index through the loop}
- itemtype : integer; {the dialog items type}
- itemhandle : handle; {the dialog items handle}
- itemrect : rect; {the dialog items rect}
- BEGIN
- FOR index := first TO last DO {do it for all items in the group}
- BEGIN
- GetDItem(theDlog, index, itemtype, itemhandle, itemrect); {get the handle}
- if itemhandle<>nil then begin
- IF (index = item) THEN
- SetCtlValue(controlhandle(itemhandle), 1) {hilite the control}
- ELSE
- SetCtlValue(controlhandle(itemhandle), 0); {unlilite the control}
- end;
- END;
- END;
-
-
- FUNCTION GetRadioButton;
- {gets the first checked ITEM in dialog. returns 0 if none is checked.}
-
- VAR
- loopindex, index : integer; {index through the loop}
- itemtype : integer; {the dialog items type}
- itemhandle : handle; {the dialog items handle}
- itemrect : rect; {the dialog items rect}
- BEGIN
- index := 0; loopindex := first;
- WHILE (loopindex <= last) AND (index = 0) DO
- BEGIN {do it for all items in the group}
- GetDItem(theDlog, loopindex, itemtype, itemhandle, itemrect); {get the handle}
- if itemHandle<>nil then
- IF GetCtlValue(controlhandle(itemhandle)) = 1 THEN
- index := loopindex; {hilited control ?}
- loopindex := loopindex + 1;
- END;{while}
- getRadioButton := Index;
- END;
-
-
- PROCEDURE ItemSetText (TheDialog : dialogptr;ItemNo : integer;itext : str255);
- {set itext to static/edit/ctl item ItemNo}
- VAR
- ItemType : Integer;
- ItemBox : Rect;
- ItemHdl : Handle;
- port : GrafPtr;
- BEGIN
- GetDItem(theDialog, ItemNo, ItemType, ItemHdl, ItemBox);
- ItemType := itemType MOD ItemDisable; {10. 9.86 hide Disable flag}
- hlock(handle(ItemHdl));
- IF ((itemtype = statText) OR (itemtype = editText)) THEN
- SetIText(ItemHdl, itext)
- ELSE IF itemType < statText THEN
- setctitle(ControlHandle(ItemHdl), itext); {Noop for pictures etc.}
- hunlock(handle(ItemHdl));
- END;
-
-
-
- PROCEDURE ItemGetText (TheDialog : dialogptr;ItemNo : integer;VAR itext : str255);
- VAR
- ItemType : Integer;
- ItemBox : Rect;
- ItemHdl : Handle;
- BEGIN
- GetDItem(theDialog, ItemNo, ItemType, ItemHdl, ItemBox);
- ItemType := itemType MOD ItemDisable; {10. 9.86 hide Disable flag}
- hlock(handle(ItemHdl));
- IF (itemtype = statText) OR (itemtype = editText) THEN
- GetIText(ItemHdl, itext)
- ELSE IF itemType < statText THEN
- getctitle(ControlHandle(ItemHdl), itext);
- {Noop for pictures etc.}
- hunlock(handle(ItemHdl));
- END;
-
- PROCEDURE FrameItem;
- VAR
- ItemType : Integer;
- ItemBox : Rect;
- ItemHdl : Handle;
- oldPen : PenState;
- BEGIN
- drawControls(WindowPtr(TheDialog));
- GetPenState(oldPen);
- PenNormal;
- PenSize(3, 3);
- GetDItem(theDialog, ItemNo, ItemType, ItemHdl, ItemBox);
- InSetRect(ItemBox, -4, -4);
- FrameRoundRect(ItemBox, 16, 16);
- SetPenState(oldPen);
- END;
-
-
- FUNCTION ItemGetReal;
- VAR mstr : str255;
- BEGIN
- ItemGetText(theDialog, ItemNo, mstr); ItemGetReal := str2Num(mstr);
- END;
-
- PROCEDURE ItemSetReal;
- VAR dstr : decstr;
- BEGIN
- num2str(Form, value, dstr); ItemSetText(theDialog, ItemNo, dstr);
- END;
-
- FUNCTION ItemGetNum;
- VAR dstr : str255;
- value : longint;
- BEGIN
- ItemGetText(theDialog, ItemNo, dstr); stringToNum(dstr, value);
- ItemGetNum := value;
- END;
-
- PROCEDURE ItemSetNum;
- VAR dstr : str255;
- BEGIN
- numToString(value, dstr); ItemSetText(theDialog, ItemNo, dstr);
- END;
- {queue.ipl implementation of an information-oriented queue}
-
- procedure QueueInit{(var theStatus: univ tQueueStatus)};
- {set all entries in theStatus to nil}
- begin
- with theStatus do
- begin
- first:=nil;
- last:=nil;
- current:=nil;
- end;
- end;
-
- function AddPtr{(thePtr: univ Ptr;var theQueueStatus: univ tQueueStatus):osErr};
- {add the entry thePtr after Queue described by theQueueStatus}
- var tempPtr:tQueuePtr;
- begin
- new(tempPtr);
- if tempPtr=nil
- then AddPtr:=nilHandleErr {MemError}
- else begin
- AddPtr:=NoErr;
- with tempPtr^ do begin
- infoPtr:=thePtr;
- nextQElem:=nil;
- end;
- with theQueueStatus do
- begin
- if first=nil then first:=tempPtr;
- if last<>nil then last^.nextQElem:=tempPtr;
- last:=tempPtr;
- end;
- end;
- end;
-
- function nextinfoPtr{(var theQueueStatus: univ tQueueStatus):Ptr};
- {Get an entry from current position of Queue described by theQueueStatus.
- Advances pointer: first ... last .. nil.. first..
- Does n o t delete queue entry}
- var tempPtr:tQueuePtr;
- tempElem:tQueueElem;
- begin
- with theQueueStatus do
- begin
- if first=nil then nextinfoPtr:=Nil
- else begin
- if current=nil then current:=first;
- nextinfoPtr:=current^.infoPtr;
- current:=current^.nextQElem;
- end;
- end;
- end;
-
- procedure DiscardPtr{(thePtr: univ Ptr;var theQueueStatus: univ tQueueStatus)};
- {Discard an entry from the Queue. Does n o t discard the info.
- Does nothing, if entry is not found. Advances Current, if necessary}
- var tempPtr:tQueuePtr;
- tempMemory:tQueuePtr;
- tempElem:tQueueElem;
- begin
- tempMemory:=nil;
- tempPtr:=theQueueStatus.first;
- while (tempPtr<>nil) and (tempPtr^.infoPtr<>thePtr) do
- begin {try to find thePtr at info position}
- tempMemory:=tempPtr;
- tempPtr:=tempPtr^.nextQElem;
- end;
- if tempPtr<>nil then begin
- if tempMemory<>nil then {bridge links}
- tempMemory^.nextQElem:=tempPtr^.nextQElem;
- with theQueueStatus do begin {update the queue}
- if first=tempPtr then first:=tempPtr^.nextQElem;
- if current=tempPtr then current:=tempPtr^.nextQElem;
- if last=tempPtr then last:=tempMemory;
- end; {with theQueueStatus}
- dispose(tempPtr);
- end;
- end;
-
- Procedure DiscardFirst{(var theQueueStatus: univ tQueueStatus)};
- {Special case: discard first entry in queue}
- var tempPtr:tQueuePtr;
- begin
- with theQueueStatus do begin
- if first<>nil then begin
- tempPtr:=first;
- if current=first then current:=first^.nextQElem;
- if last=first then current:=first^.nextQElem;
- first:=first^.nextQElem;
- dispose(tempPtr);
- end;
- end;
- end;
-
-
-
- { M i s c a l l a n e o u s R o u t i n e s}
-
- { U n d o s u p p o r t }
-
- PROCEDURE ForgetUndo;
- begin
- if gUndoHandle<>nil then begin
- ReleaseResource(gUndoHandle); {maybe it was a resource}
- if ResError<> noErr then disposHandle(gUndoHandle); {should be safer…}
- end;
- gUndoHandle:=nil;
- gUndoType:=' ';
- gUndoOwner:=Nil;
- gUndoAction:=cCantUndo;
- end;
-
- FUNCTION PutUndo{(info:handle;infoType:ResType;owner:ptr;cmd:cmdNumber):OsErr};
- {note the info for undo. makes a copy of info}
- VAR MyErr:OsErr;
- BEGIN
- ForgetUndo;
- gUndoHandle:=info;
- MyErr:=HandToHand(gUndoHandle);{make a copy of info and handle}
- if MyErr=NoErr then begin
- gUndoType:=infoType;
- gUndoOwner:=owner;
- gUndoAction:=cmd;
- END;
- PutUndo:=MyErr;
- END;
-
- FUNCTION GetUndo{(var info:handle;var infoType:ResType;
- var owner:ptr;var cmd:cmdNumber):OsErr};
- {returns a copy of the undo info, or NIL}
- VAR MyErr:OsErr;
- BEGIN
- info:=gUndoHandle;
- if info=nil then GetUndo:= noTypeErr else begin
- MyErr:=HandToHand(info);{make a copy of info and handle}
- if MyErr=NoErr then
- begin
- infoType:=gUndoType;
- owner:=gUndoOwner;
- cmd:=gUndoAction;
- END
- Else info:=nil;
- GetUndo:=MyErr;
- end; {info available}
- END;
-
-
- { s t r i n g s u p p o r t }
-
-
- {function lefttrim (s : str255) : str255;}
- FUNCTION lefttrim;
- VAR i, j : integer;
- BEGIN
- j := length(s);
- IF j = 0 THEN lefttrim := ''
- ELSE BEGIN
- i := 0;
- REPEAT i := succ(i) UNTIL (i = j) OR ((s[i] <> ' ') and (ord(s[i])<>9));
- IF ((s[i] <> ' ') and (ord(s[i])<>9))
- THEN lefttrim := copy(s, i, j - i + 1)
- ELSE lefttrim := '';
- END;
- END;{lefttrim}
-
- {function righttrim (s : str255) : str255;}
- FUNCTION righttrim;
- VAR
- i, j : integer;
- BEGIN j := length(s);
- IF j = 0 THEN righttrim := '' ELSE
- BEGIN
- i := j + 1;
- REPEAT
- i := pred(i)
- UNTIL (i = 1) OR ((s[i] <> ' ') and (ord(s[i])<>9));
- IF ((s[i] <> ' ') and (ord(s[i])<>9))
- THEN righttrim := copy(s, 1, i) else righttrim := '';
- END;
- END;{righttrim}
-
-
- { u s e r i n t e r r u p t }
-
- {check for apple dot. Horst Degen, 15.12.85}
- FUNCTION PAbortFlag;
- VAR
- myQElemPtr : QElemPtr;
- aChar : Char;
- myQHdrP : QHdrPtr;
- BEGIN
- PAbortFlag := false;
- myQHdrP := GetEvQHdr;
- myQElemPtr := myQHdrP^.qHead;
- WHILE myQElemPtr <> NIL DO
- BEGIN
- IF myQElemPtr^.evQElem.evtQwhat = keydown THEN
- BEGIN
- aChar := CHR(BitAnd(myQElemPtr^.evQElem.evtQmessage, charCodeMask));
- IF (aChar = '.') AND (BitAnd(myQElemPtr^.evQElem.evtQmodifiers, cmdKey) <> 0) THEN
- BEGIN
- PAbortFlag := True;
- myQElemPtr := NIL;
- END;
- END;
- IF myQElemPtr <> NIL THEN
- myQElemPtr := myQElemPtr^.evQElem.qlink;
- END;
- END;
-
-
- { p r o g r e s s r e p o r t }
-
- PROCEDURE showprogress;
- BEGIN
- IF progressdialog <> NIL THEN
- BEGIN showHide(windowptr(progressdialog), True);
- Drawdialog(progressdialog);
- END;
- END;
-
- PROCEDURE progressreport;
- BEGIN
- IF progressdialog <> NIL THEN
- BEGIN
- showHide(windowptr(progressdialog), True);
- selectwindow(windowptr(progressdialog));
- ItemSetText(ProgressDialog, item + 1, what);
- systemtask;
- END;
- END;
-
- PROCEDURE hideprogress;
- VAR
- i : integer;
- BEGIN
- IF progressdialog <> NIL THEN
- BEGIN
- FOR i := 1 TO 4 DO
- ItemSetText(ProgressDialog, i + 1, '');
- showHide(windowptr(progressdialog), False);
- END;
- END;
-
-
- { M I S C A L L A N E O U S }
-
-
- PROCEDURE idstamp {(user : str255; VAR stampstring : str255)};
- {gives a standard identification string in stampstring.
- stampstring is build from USER and the current time information.}
- CONST
- usrlen = 3;
- VAR
- now : DateTimeRec;
- build, buildhex : str255;
- FUNCTION cxhex (par : longint) : char;
- VAR
- tpar : integer;
- BEGIN
- tpar := abs(par MOD 34);
- IF tpar < 10 THEN
- cxhex := chr(tpar + ord('0'))
- ELSE
- cxhex := chr(tpar - 10 + ord('A'));
- END; {cxhex}
-
-
- PROCEDURE hexstr (par : longint; VAR tostr : str255);
- { par -> toStr, Laenge nrlen }
- VAR
- rest : longint;
- i : integer;
- BEGIN
- tostr := ' ';
- rest := par;
- IF rest < 0 THEN
- rest := abs(rest) - 1;
- FOR i := length(tostr) DOWNTO 1 DO
- BEGIN
- tostr[i] := cxhex(rest MOD 16);
- rest := rest DIV 16;
- END;
- END;{hexstr}
-
- BEGIN {idstamp}
- stampstring := user;
- delete(stampstring, usrlen + 1, 255);
- getTime(now);
- WITH now DO
- BEGIN
- build := ' ';
- build[1] := cxhex(year - 1980);
- build[2] := cxhex(month);
- build[3] := cxhex(day DIV 10);
- build[4] := cxhex(day MOD 10);
-
- hexstr(minute * 60 + second, buildhex);
- buildhex[1] := cxhex(hour);
- END;
- stampstring := concat(stampstring, ' ', build, ' ', buildhex);
- END;{idstamp}
-
-
- { C l e a r P i c / S e t W i n d o w }
-
- {clear the picture associated to a window}
- PROCEDURE clearwindow;
- VAR
- r : rect;
- pic : pichandle;
- s : str255;
- BEGIN
- pic := getwindowpic(window);
- IF pic <> NIL THEN
- BEGIN
- setwindowpic(window, NIL);
- killpicture(pic);
- END;
- setport(window);
- eraserect(theport^.portrect);
- validrect(theport^.portrect);
- END;
-
-
- PROCEDURE setwport;
- BEGIN
- setport(window);
- selectwindow(window);
- showwindow(window);
- END;
-
-
- End.
-